package com.victor.core.util;

public class MobilePhoneHolder {
    /**
     * 获取两个字符串 最大连续数字 相等值
     *
     * @return
     */
    public static int getSustainNum(String str1, String str2) {
        char[] ch1 = str1.toCharArray();
        char[] ch2 = str2.toCharArray();
        int max = 0;
        int len1 = str1.length();
        char c;
        for (int i = 0; i < len1; i++) {
            String temp = "";
            for (int j = 0; j <= i; j++) {
                c = ch1[j];
                if (!Character.isDigit(c)) {
                    //如果不是数字
                    temp = "";
                    continue;
                }
                temp += String.valueOf(c);
            }
            if (str2.indexOf(temp) != -1) {
                // 如果字符串 包含 当前串
                max = Math.max(max, temp.length());
            }
        }
        int len2 = str2.length();
        for (int i = 0; i < len2; i++) {
            String temp = "";
            for (int j = 0; j <= i; j++) {
                c = ch2[j];
                if (!Character.isDigit(c)) {
                    //如果不是数字
                    temp = "";
                    continue;
                }
                temp += String.valueOf(c);
            }
            if (str1.indexOf(temp) != -1) {
                // 如果字符串 包含 当前串
                max = Math.max(max, temp.length());
            }
        }
        return max;
    }

    public static void main(String[] args) {
        System.out.println(getSustainNum("1372;004t7167;", "；；；13720047167;"));
    }
}
